//
//  XiugaitouxiangTableViewController.m
//  YSZC
//
//  Created by 张斌 on 16/4/21.
//  Copyright © 2016年 YueShiKeJi. All rights reserved.
//

#import "XiugaitouxiangTableViewController.h"
#import "takePhoto.h"

@interface XiugaitouxiangTableViewController ()
@property (weak, nonatomic) IBOutlet UIButton *headerimgview;

@end

@implementation XiugaitouxiangTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
 
    if (cell.tag == 101) {
        [takePhoto sharePicture:^(UIImage *image) {
            [self.headerimgview setImage:image forState:UIControlStateNormal];
        } :^(UIImagePickerController *pickerVc) {
            [self presentViewController:pickerVc animated:YES completion:nil];
        }];

        // 选择并且更换头像
//        UIImagePickerController* picker = [[UIImagePickerController alloc] init];
//        picker.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;
//        picker.allowsEditing = YES;
//        
//        picker.delegate = self;
//        
//        [self presentViewController:picker animated:YES completion:nil];
    }
}

//- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
//    [self dismissViewControllerAnimated:YES completion:nil];
//    
//    UIImage*image = info[UIImagePickerControllerOriginalImage];
//    [self.headerimgview setImage:image forState:UIControlStateNormal];
//}
//
//- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
//    [self dismissViewControllerAnimated:YES completion:nil];
//}
//
//- (void)image:(UIImage*)image didFinishSavingWithError:(NSError*)error contextInfo:    (void*)contextInfo{
//    
//    if(error) {
//        
//        //        [MBProgressHUDshowError:@"保存失败"];
//        
//    }else{
//        
//        //        [MBProgressHUDshowSuccess:@"保存成功"];
//    }
//}

@end
